<template>
  <div class="left-nav">
    <div
      :style="{
        fontWeight: selectIndex === index ? '700' : '',
        background: selectIndex === index ? '#fff' : '',
      }"
      v-for="(item, index) in categoryList"
      :key="index"
      @click="onClick(index)"
    >
      {{ item.categoryName }}
    </div>
  </div>
</template>
<script>
export default {
  props: {},
  data() {
    return {};
  },
  //事件处理器
  methods: {
    onClick(index) {
      this.$store.dispatch("SelectIndex", index);
    },
  },
  // 计算属性
  computed: {
    categoryList() {
      return this.$store.state.DetailsData.categoryList;
    },
    selectIndex() {
      return this.$store.state.selectIndex;
    },
  },
  //侦听器
  watch: {},
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
};
</script>
<style scoped>
/* @import url(); 引入css类 */
.left-nav {
  width: 100%;
  background: #f5f5f5;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.left-nav div {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5625rem 0.625rem 1.375rem 0.625rem;
}
</style>
